package com.alibaba.citrus.cr.unified.inventory.model.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * @author wanwy
 * @description 运输方式
 */
public enum TransportModeEnum {
    AUTOMOBILE_TRANSPORTATION_DISTRIBUTION("01","汽运配送"),
    RAILWAY_TRANSPORTATION_DISTRIBUTION("02","铁运配送"),
    OCEAN_SHIPPING_DISTRIBUTION("03","海运配送"),
    AIR_TRANSPORT_DISTRIBUTION("04","空运配送"),
    AUTOMOBILE_TRANSPORTATION_TAKE_FROM_ONESELF("05","汽运自提"),
    LESS_THAN_CARLOAD_TRANSPORTATION("06","零担运输"),
    CONTAINER_CHANGE_AUTOMOBILE_TRANSPORTATION_DISTRIBUTION("07","集改汽配送"),
    WATER_AND_ELECTRICITY_TRANSMISSION("09","水电气输送");
    private String code;

    private String desc;

    TransportModeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 通过code获取枚举
     *
     * @param code code
     * @return by code
     */
    public static TransportModeEnum getByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        for (TransportModeEnum transportModeEnum : values()) {
            if (StringUtils.equalsIgnoreCase(code, transportModeEnum.getCode())) {
                return transportModeEnum;
            }
        }
        return null;
    }
}
